<?php

class ErrorPageException extends Exception{
	public function __construct($msg){
		if(!DEBUG){
			header("HTTP/1.0 404 Not Found");
			echo "<body style='background-color:#f0f0f0;'><center><div style='margin:30px;padding:30px;border:1px solid #A0A0A0;-moz-border-radius:10px;width:50%;font-family:Segoe UI;text-align:left;color:#000;background-color:#fff;'><h1>Can't display the page requested.<hr/></h1><h5>Error message:<br/></h5><pre>".$msg."</pre></div></center></body>";
			exit;
		};
		parent::__construct($msg);				
	}
}

class MySQLException extends Exception{	
	private $errordata=Array();
	private $engine=NULL;
	
	public function __construct($p){
		$this->engine=&$p;
		$msg=mysqli_error($p);
		parent::__construct($msg);			
	}
	
	public function __get($p){
		if(isset($data[$p]))return $data[$p];
		return NULL;
	}
	
	public function isTableDoesntExist(){
		return (substr($this->message,-13)=="doesn't exist");		
	}	
	
	public function isCannotBeNull(){
		return (substr($this->message,-14)=="cannot be null");
	}
	
	public function getSubject(){
		if(preg_match('/\'(.*)\'/',$this->message,$o))return $o[1];
		return NULL;
	}
};